package huawei_nowcoder;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @Description: 学英语
 * @Date: 2020/4/24
 * @Author: 许群星
 */
public class LearnEnglish {
    static Map<Integer, String> map=new HashMap<>();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()){
            int a=sc.nextInt();
            System.out.println(convertEnglish(a));
        }
    }
    //数字转英语     通过40用例
    public static String convertEnglish(int a){
        //把数字对应的放入map中直接取对应的即可
//        Map<Integer, String> map=new HashMap<>();
        //0-9
        map.put(0,"zero");
        map.put(1,"one");
        map.put(2,"two");
        map.put(3,"three");
        map.put(4,"four");
        map.put(5,"five");
        map.put(6,"six");
        map.put(7,"seven");
        map.put(8,"eight");
        map.put(9,"nine");
        //10-19
        map.put(10,"ten");
        map.put(11,"eleven");
        map.put(12,"twelve");
        map.put(13,"thirteen");
        map.put(14,"fourteen");
        map.put(15,"fifteen");
        map.put(16,"sixteen");
        map.put(17,"seventeen");
        map.put(18,"eighteen");
        map.put(19,"nineteen");
        //20 90
        map.put(20,"twenty");
        map.put(30,"thirty");
        map.put(40,"forty");
        map.put(50,"fifty");
        map.put(60,"sixty");
        map.put(70,"seventy");
        map.put(80,"eighty");
        map.put(90,"ninety");
        //100 1000 100，0000
        map.put(100,"hundred");
        map.put(1000,"thousand");
        map.put(1000000,"million");
        map.put(1000000000,"billion");

        //边缘
        if (a<0||a>999999999) {
            return "error";
        }
        if(a<100){
            return first(a);
        }else if (a<1000){
            return second(a);
        }else if (a<100000){
            return third(a);
        } else if (a < 1000000) {
            return fourth(a);
        }else {
            return fifth(a);
        }

    }
    //0-100          零到一百
    private  static String first(int a){
        if(a<20){
            return map.get(a);
        }else {
            String ans = "";
            ans += map.get(a / 10 * 10);
            ans += " ";
            ans += map.get(a % 10);
            return ans;
        }
    }
    //100-1000      一百到一千
    private  static String second(int a){
        String ans="";
        ans+=map.get(a/100);
        ans += " hundred and ";
        int temp=a%100;
        ans+=map.get(temp/10*10);
        ans+=" ";
        ans+=map.get(temp%10);
        return ans;
    }
    //1000-10 0000        一千到十万
    private  static String third(int a){
        String ans="";
        ans+=first(a/1000);
        ans += " thousand ";
        int temp=a%1000;
        if (temp<100) {
            ans+=first(temp);
        } else {
            ans+=second(temp);
        }
        return ans;
    }
    //10 0000-100 0000     十万到一百万
    private  static String fourth(int a){
        String ans="";
        ans+=second(a/1000);
        ans+=" thousand ";
        int temp=a%1000;
        if (temp<100) {
            ans+=first(temp);
        } else if (temp<1000){
            ans+=second(temp);
        }else {
            ans+=third(temp);
        }
        return ans;
    }
    //100 0000-    1 0000 0000   一百万到一亿
    private  static String fifth(int a){
        String ans="";
        int haha=a/1000000;
        if (haha<100) {
            ans+=first(a/1000000);
        } else {
            ans+=second(a/1000000);
        }
        ans += " million ";
        int temp=a%1000000;
        if (temp<100) {
            ans+=first(temp);
        } else if (temp<1000){
            ans+=second(temp);
        }else if (temp<10000){
            ans+=third(temp);
        }else {
            ans+=fourth(temp);
        }
        return ans;
    }
}
/*
题目描述
Jessi初学英语，为了快速读出一串数字，编写程序将数字转换成英文：
如22：twenty two，123：one hundred and twenty three。
说明：
数字为正整数，长度不超过九位，不考虑小数，转化结果为英文小写；
输出格式为twenty two；
非法数据请返回“error”；
关键字提示：and，billion，million，thousand，hundred。
方法原型：public static String parse(long num)
输入描述:
输入一个long型整数
输出描述:
输出相应的英文写法
示例1
输入
复制
2356
输出
复制
two thousand three hundred and fifty six
 */